###
## @file makefile
## Betriebssysteme Makefile
## 
## Beispiel 2
##
## @author Markus Scharitzer 1410258040 <markus.scharitzer@technikum-wien.at>
## @date 2015/03/16
##
## @version 0.1
##
## Makefile
##
###


##
## ------------------------------------------------------------- variables --
##

CC=gcc
CFLAGS=-DDEBUG -ggdb -Wall -pedantic -Werror -Wextra -Wstrict-prototypes -fno-common -g -O3 
CP=cp
CD=cd
MV=mv
GREP=grep
DOXYGEN=doxygen

OBJECTS=mypopen.o

EXCLUDE_PATTERN=footrulewidth

##
## ----------------------------------------------------------------- rules --
##

%.o: %.c
	$(CC) $(CFLAGS) -c $<

##
## --------------------------------------------------------------- targets --
##

all: mypopen doc

mypopen: $(OBJECTS)
	$(CC) $(CFLAGS) -o popentest $^ -lpopentest
	$(CC) $(CFLAGS) -o test-pipe $^ -ltest-pipe 

clean:
	$(RM) *.o *~ popentest test-pipe

distclean: clean
	$(RM) -r doc

doc: html

html:
	$(DOXYGEN) doxygen.dcf



pdf: html
	$(CD) doc/pdf && \
	$(MV) refman.tex refman_save.tex && \
	$(GREP) -v $(EXCLUDE_PATTERN) refman_save.tex > refman.tex && \
	$(RM) refman_save.tex && \
	make && \
	$(MV) refman.pdf refman.save && \
	$(RM) *.pdf *.html *.tex *.aux *.sty *.log *.eps *.out *.ind *.idx \
	      *.ilg *.toc *.tps Makefile && \
	$(MV) refman.save refman.pdf
